package com.example.demo.mapper;

import com.example.demo.entity.Admin;
import org.apache.ibatis.annotations.*;

import java.util.List;
@Mapper
public interface AdminMapper {

    //判断管理员登录用户名和密码正确性
    @Select("SELECT * FROM admin_tb WHERE name = #{name} AND password = #{password}")
    Admin findAdmin(@Param("name") String name, @Param("password") String password); // 查找管理员

    //查找所有管理员信息
    @Select("select * from admin_tb")
    List<Admin>findAdminAll();

    //根据ID查找管理员信息
    @Select("select * from admin_tb where admin_id = #{admin_id}")
    Admin findAdminID(Integer admin_id);

    //添加管理员信息
    @Insert("insert into admin_tb (admin_id,name,password,sex,birthday)" +
            "values (#{admin_id},#{name},#{password},#{sex},#{birthday})" )
    Integer insertAdmin(Admin admin);

    //修改管理员信息
    @Update("update admin_tb set admin_id=#{admin_id},name=#{name},password=#{password},sex=#{sex},birthday=#{birthday} where admin_id = #{admin_id}")
    Integer updateAdmin(Admin admin);

    //删除学生信息
    @Delete("delete from admin_tb where admin_id = #{admin_id}")
    Integer deleteAdmin(Integer admin_id);

}
